define("pages/jls_sj/jkjcmain", [
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate",
        "../../common/tools",
        "../../common/componts",
        "../../common/kss",
        "../../pages/jls_sj/formjkjc",
    ],
    function(require) {
        var comonts=require("../../common/componts");
        var kss=require("../../common/kss");
        var jkjcdialog=require("../../pages/jls_sj/formjkjc");
        var jkjcId="jkjcId";
        var jbxxrightmenuid="rightmenu";
        var selectid;
        var id;
        var jkjc="jkjc";
        var jbxx="jbxx";
        var initTable=function(){
            comonts.initTable(jkjcId,{
                height:'615px',
                url:"/jls_jbxx/jbxxList",
                fit:true,
                tools:'#jkjcTool',
                columns :  [
                    {
                        field: 'oid',
                        title: '',
                        formatter: function(value, rowData, rowIndex){
                            return '<input type="radio" name="selectRadio1" id="sykzRadio1"' + rowIndex + 'value="' + rowData.oid + '" />';
                        }},
                    {field : 'xm',width : 100,title:'姓名',sortable:'true',formatter: function(value,row,index){return '<span title='+(value==null?"":value)+'>'+(value==null?"":value)+'</span>'}},
                    {field : 'bm',width : 100,title:'别名',sortable:'true',formatter: function(value,row,index){return '<span title='+(value==null?"":value)+'>'+(value==null?"":value)+'</span>'}},
                    {field : 'xb',title : '性别',hidden:false,width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xbString==null?"":row.xbString)+'>'+(row.xbString==null?"":row.xbString)+'</span>'}},
                    {field : 'csrq',title : '出生日期',width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(value==null?"":value)+'>'+(value==null?"":value)+'</span>'}},
                    {field : 'rsrq',title : '入所日期',width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(value==null?"":value)+'>'+(value==null?"":value)+'</span>'}},
                    {field : 'bahj',title : '办案环节',width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bahjString==null?"":row.bahjString)+'>'+(row.bahjString==null?"":row.bahjString)+'</span>'}},
                    {field : 'ay',title : '涉嫌罪名',width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.ayString==null?"":row.ayString)+'>'+(row.ayString==null?"":row.ayString)+'</span>'}},
                    {field : 'hjd',title : '户籍所在地',width : 200,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.hjdString==null?"":row.hjdString)+'>'+(row.hjdString==null?"":row.hjdString)+'</span>'}},
                    {field : 'rsxz',title : '入所性质',width : 200,hidden:true,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.rsxzString==null?"":row.rsxzString)+'>'+(row.rsxzString==null?"":row.rsxzString)+'</span>'}},
                    {field:'operate',title:'详细信息',align:'center',width : 60,/*width:$(this).width()*0.15,*/
                        formatter:function(value, row, index){
                            var str = '<a href="#"  data-target="#ckPhoto" value="'+index+'" name="opera" data-toggle="modal" class="easyui-linkbutton"><img src="../../img/xq.png"></a>';
                            return str;
                        }
                    }
                ] ,

                onLoadSuccess:function(data){
                    if(data.total>0){
                        $('#'+jkjcId).datagrid("selectRow", 0);
                        $("input[name='selectRadio1']")[0].checked = true;
                    }

                    $("a[name='opera']").each(function(){
                        $(this).on('click',function(){
                            var index = $(this).attr('value');
                            var jbxx = data.rows[index];
                            kss.initJbxxxx(jbxx.gcbh,jbxx.rybh,jbxx.xm+"--详细信息");
                        });
                    });

                },
                //单击行选中取消事件
                onClickRow: function (rowIndex, rowData) {
                    if(id!=rowData.id){
                        $("input[name='selectRadio1']")[rowIndex].checked = true;
                        $('#jkjcId').datagrid("selectRow", rowIndex);
                        id=rowData.id;
                    }else if(id==rowData.id){
                        $('#jkjcId').datagrid("unselectRow",rowIndex);
                        $("input[name='selectRadio1']")[rowIndex].checked = false;
                        id="";
                    }
                },
                //datagrid详细信息
                detailFormatter:function(index,rowData){
                    if(rowData.bz==null){
                        rowData.bz=" ";
                    }
                    return '<table><tr><td>备注:'+rowData.bz+'</td></tr></table>'
                },
                //双击事件
                onDblClickRow: function (rowIndex, rowData) {
                    //获得当前时间
                    var d = new Date();
                    var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
                    $('#dlg input').attr("disabled","disabled");
                    $("input[name='selectRadio1']")[rowIndex].checked = true;//选中radio按钮
                    $('#'+jkjcId).datagrid("selectRow", rowIndex);
                    id=rowData.id;//选中取消事件id
                    var jkjcId = $('#jkjcId').datagrid('getSelected');
                    jkjcdialog.show(rowData,{},refreshTable);
                    $('#jcrqfm').datebox('setValue',str);
                    $('#gcbhfm').textbox('textbox').css('background','#EBEBE4')
                    $('#xmfm').textbox('textbox').css('background','#EBEBE4')
                },
                queryParams : {
                    "processDefinitionKey":comonts.getUrlParam('processDefinitionKey'),
                    "taskDefinitionKey":comonts.getUrlParam('taskDefinitionKey'),
                    "pageSize" : function(){
                        return $('#jkjcId').datagrid("getPager").pagination("options").pageSize;
                    },
                    "pageIndex" : function(){
                        return $('#jkjcId').datagrid("getPager").pagination("options").pageNumber;
                    }
                }
            });
            //页面高度自适应
            $('#'+jkjcId).datagrid('resize',{
                height:($(window).height()-130)
            });
        }
        //监室监区
        var initJsTree=function(){
            kss.initJsTree("jqjsTree","jkjcId",{});
        }
        //人员基本信息根据人员编号及姓名查询
        var findjkjc=function(){
            var s_xmsr = $("#xm").textbox('getValue');
            var xm_type=$("#xm_type").textbox("getValue");
            var jsh=$("#jsh").textbox("getValue");
            var jsh_type=$("#jsh_type").textbox("getValue");
            var bm=$("#bm").textbox("getValue");
            var bm_type=$("#bm_type").textbox("getValue");
            var xb=$("#xb").textbox("getValue");
            var xb_type=$("#xb_type").textbox("getValue");
            console.log(s_xmsr+"+++"+xm_type)
            $('#'+jkjcId).datagrid('load',{
                "taskDefinitionKey":getUrlParam('taskDefinitionKey'),
                "processDefinitionKey":getUrlParam('processDefinitionKey'),
                'xm': s_xmsr,
                'xm_type':xm_type,
                'jsh':jsh,
                'jsh_type':jsh_type,
                'bm':bm,
                'bm_type':bm_type,
                'xb':xb,
                'xb_type':xb_type,
                "pageSize" : function(){
                    return $('#jkjcId').datagrid("getPager").pagination("options").pageSize;
                },
                "pageIndex" : function(){
                    return $('#jkjcId').datagrid("getPager").pagination("options").pageNumber;
                }
            });
        }
        var initToolAction=function(){
            //获得当前时间
            var d = new Date();
            var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
            //新增
            $("#jkjc_add").on("click",function(){
                var jkjc=$("#"+jkjcId).datagrid('getSelected');
                if(jkjc){
                    jkjcdialog.show(jkjc,{},refreshTable);
                }else{
                    $.messager.alert("提示","请选择要办理的人员!","info");
                }
            });
            //查询事件
            $("#jkjc_select").on("click",function(){
                findjkjc();
            });
            //回车查询事件
            $(window).keydown(function(event) {
                if (event.keyCode == 13) {
                    findjkjc();
                }
            });
            //高级查询
            $("#gcSelect").on("click",function(){
                gjSelectForm.show();
            });
            //查看图示说明
            $('#hint').tooltip({
                position : 'top',
                content : '<div style="height: 63%;"><div class="top" style="font-size: 12px;margin-bottom: 5px;"><strong>图示说明</strong></div><div class="lump" style="background-color: #e9540e; width: 20px;height: 30px;"></div><div class="lump" style="margin-right: 10px; ">重大一级<br /></div><div class="lump" style="background-color: #ffab2e; width: 20px;height: 30px;"></div><div class="lump" style="margin-right: 10px; ">重大二级<br /></div><div class="lump" style="background-color: #006e44; width: 20px;height: 30px;"></div><div class="lump" style="margin-right: 10px; ">重大三级<br /></div></div>',
                onShow : function() {
                    $(this).tooltip('tip').css({
                        backgroundColor : '#ececec'

                    });
                }
            });
        }
        var refreshTable=function(data){
            $('#'+jkjcId).datagrid('reload',{rybh:$('#'+jkjcId).datagrid('getSelected').rybh});
        }
        var initView=function(){
            initTable();
            initJsTree();
            initToolAction();
        }
        initView();
    });